<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>计数器</title>
</head>

<body>
    <!-- 要挂载的节点 -->
    <div id="root"></div>
    <!-- 引入依赖 -->
    <script src="../lib/react.js"></script>
    <script src="../lib/react-dom.js"></script>
    <script src="../lib/babel.js"></script>
    <!-- 设置类型为text/babel 否则浏览器无法解析jsx -->
    <script type="text/babel">
        // 1.定义app组件
        class App extends React.Component {
            constructor() {
                super()
                this.state = {
                    counter: 100,
                    message: "Hello World",
                    names: ["abc", "cba", "nba"],

                    aaa: undefined,
                    bbb: null,
                    ccc: true,

                    firstName: "Kobe",
                    lastName: "bryant",

                    age: 20,

                    movies: ["流浪地球", "星际穿越", "独行月球"]

                }
            }

            render() {
                // 1.插入标识符
                const { message, names, counter } = this.state
                const { aaa, bbb, ccc } = this.state
                const { friend } = this.state
                // 2.对内容进行运算后显示(插入表示)
                const { firstName, lastName } = this.state

                return (
                    <div>
                        {/* Number/String/Array 可以直接显示出来 */}
                        <h2>{message}</h2>

                    </div>
                )
            }
        }
        // 2.创建root并且渲染App组件
        const root = ReactDOM.createRoot(document.querySelector("#root"))
        root.render(<App />)
    </script>
</body>

</html>